window.onload = function(){

    // 延时加载动画一
    setTimeout(function(){
        $(".item1 .text-wrap").addClass('fadeInDown');
    },1000);

    //  导航二维码
    $('.top-download').mouseenter(function(){
        setTimeout(function(){
            $('.down-erweima').removeClass('hidden');
        }, 10);
    });
    $('.top-download').mouseleave(function(){
        setTimeout(function(){
            $('.down-erweima').addClass('hidden');
        }, 100);
    });


    // 资讯详情
    $(function(){
        var href = window.location.href;
        var ihref = href.split("#");
        var infoId =  ihref[1];
        $.ajax({
            url: "http://51son.net:8088/api/information/detail",
            type: "POST",
            data: {
                informationId: infoId
            },
            success:function(result){
                var data = result.data.information;
                $(".breadcrumb .active").append(data.title);
                $('.txt-containt h2').append(data.title);
                var publishTime = data.publishTime.split(" ");
                $('.source span').append(publishTime[0]);
                $('.source em').append(data.source);
                var content = data.contentURL;
                var video = data.video;
                if (data.type == "1") {
                    var poani = $('<video>').attr('controls', 'controls').attr('autoplay', 'autoplay');
                    var source = $('<source>').attr('type', 'video/mp4').attr('src', video);
                    poani.append(source);
                    $('.txt-content').append(poani);
                }else{
                    var iframe = $('<iframe>').attr('id', 'iframeid').attr('frameborder', '0').attr('width', '606').attr('scrolling', 'no').attr('src', content);
                    $('.txt-content').append(iframe);
                }
            },
            error:function(){
                
            }
        });
        $.ajax({
            url: "http://51son.net:8088/api/information/list",
            type: "POST",
            data: {
                labelId: "1278962961c04d86ba7b2d83651e9178"
            },
            success:function(result){
                var data = result.data.rows;
                for (i = 0; i<6; i++) {
                    if( data[i].title.length > 15 ){
                        if ( document.body.clientWidth < 720 ) {
                            var titleTxT = data[i].title.substr(0,28) + "....";
                        }else{
                            var titleTxT = data[i].title.substr(0,15) + "....";
                        }
                    }else{
                        var titleTxT = data[i].title;
                    }
                    var a = $("<a>").attr("href", 'Information-detail.html' + '#' + data[i].informationId).append(titleTxT).attr('target', '_blank');
                    var li = $('<li>');
                    li.append(a);
                    $(".related ul").append(li);
                }

            }
        });
    });

}